package com.buka.controller;

import com.buka.service.HotelService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/kf")
public class KfServlet extends HttpServlet {

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //修改房屋状态，修改那个房屋的状态
        String roomNumStr = req.getParameter("roomNum");
        String card = req.getParameter("card");
        int roomNum = Integer.parseInt(roomNumStr);
        //当前在controller层，需要使用service层对象
        HotelService hotelService = new HotelService();
        //开房方法最终执行的是update语句  update语句的返回值是个int
        int row = hotelService.kf(roomNum,card);
        //给浏览器回复
        resp.sendRedirect("index");//数据处理完成，让浏览器重新访问index
    }
}
